<?php
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
use Magento\Framework\View\Element\Template;
use Magento\Vault\Api\Data\PaymentTokenInterface;
use Magento\Vault\Block\CardRendererInterface;

/** @var CardRendererInterface|Template $block */

$ccNumberView = $block->escapeHtml($block->getNumberLast4Digits());
?>
<tr>
    <td data-th="<?php echo $block->escapeHtml(__('Card Number')) ?>" class="col card-number">
        <span><?php echo $block->escapeHtml(__('ending')); ?></span> <?php /* @noEscape */ echo $ccNumberView ?>
    </td>
    <td data-th="<?php echo $block->escapeHtml(__('Expiration Date')) ?>" class="col card-expire">
        <?php echo $block->escapeHtml($block->getExpDate()); ?>
    </td>
    <td data-th="<?php echo $block->escapeHtml(__('Type')) ?>" class="col card-type">
        <img src="<?php /* @noEscape */ echo $block->getIconUrl(); ?>"
             width="<?php /* @noEscape */ echo $block->getIconWidth(); ?>"
             height="<?php /* @noEscape */ echo $block->getIconHeight(); ?>"
        >
    </td>
    <td data-th="<?php echo $block->escapeHtml(__('Actions')) ?>" class="col actions">
        <form
            class="form"
            action="<?php echo $block->escapeUrl($block->getUrl('vault/cards/deleteaction')); ?>"
            method="post"
            >
            <?php echo $block->getBlockHtml('formkey')?>
            <input
                name="<?php /* @noEscape */ echo PaymentTokenInterface::PUBLIC_HASH?>"
                value="<?php /* @noEscape */ echo $block->getToken()->getPublicHash()?>"
                type="hidden"/>
            <button type="submit"
                    class="action delete"
                    data-mage-init='{
                                    "Magento_Vault/js/customer_account/deleteWidget":{
                                        "type": "popup",
                                        "modalClass": "my-credit-cards-popup",
                                        "toggleEvent": "click",
                                        "title": "<?php echo $block->escapeHtml(__('Delete')) ?>",
                                        "content": "Are you sure you want to delete this card: <?php
                                            /* @noEscape */ echo $ccNumberView
                                        ?>?"
                                    }
                                }'>
                <span><?php echo $block->escapeHtml(__('Delete')) ?></span>
            </button>
        </form>
    </td>
</tr>
